<template>
  <div>
    <SearchCard ref="searchCard" :model="search">
      <template #username>
        <el-form-item label="用户名" prop="username">
          <el-input v-model="search.username" placeholder="请输入" clearable></el-input>
        </el-form-item>
      </template>
      <template #nickname>
        <el-form-item label="用户昵称" prop="nickname">
          <el-input v-model="search.nickname" placeholder="请输入" clearable></el-input>
        </el-form-item>
      </template>
      <template #phone>
        <el-form-item label="手机号" prop="phone">
          <el-input v-model="search.phone" placeholder="请输入" clearable></el-input>
        </el-form-item>
      </template>
      <template #email>
        <el-form-item label="用户邮箱" prop="email">
          <el-input v-model="search.email" placeholder="请输入" clearable></el-input>
        </el-form-item>
      </template>
      <template #status>
        <el-form-item label="状态" prop="status">
          <el-select v-model="search.status" clearable>
            <el-option v-for="(item, key) in FROZEN_STATUS" :key="key" :value="key" :label="item" />
          </el-select>
        </el-form-item>
      </template>
      <template #btnGroup>
        <el-button type="primary" @click="handleSearch">
          <el-icon>
            <Search />
          </el-icon>
          搜索
        </el-button>
        <el-button type="default" @click="handleReset">
          <el-icon>
            <RefreshRight />
          </el-icon>
          重置
        </el-button>
      </template>
    </SearchCard>
  </div>
</template>

<script setup lang="ts">
import SearchCard from "@/components/SearchCard/index.vue";
import { User } from "@/api/interface";
import { FormInstance } from "element-plus";
import { FROZEN_STATUS } from "@/enums";
import { useSearchConfig } from "@/hooks/useTable";

const props = defineProps<{ searchEvent: (searchForm: User.IUserParams) => void }>();
const searchCard = ref<FormInstance>();
const { search, handleSearch, handleReset } = useSearchConfig<User.IUserParams>(
  {
    username: "",
    nickname: "",
    phone: "",
    email: "",
    status: "",
    deptId: ""
  },
  props,
  searchCard
);
</script>

<style scoped lang="scss"></style>
